package com.example.mybatis.demo.service;

import com.example.mybatis.demo.dao.UserInfoDao;
import com.example.mybatis.demo.model.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {

    @Autowired
    private UserInfoDao userInfoDao;
    public List<UserInfo> selectUserList() {
        return userInfoDao.selectAll();
    }

    public UserInfo selectUserByNameAndPassword(String userName, String password) {
        List<UserInfo> userInfos = userInfoDao.selectByNameAndPassword(userName, password);
        if(userInfos.size()>0){
            return userInfos.get(0);
        } else {
            return null;
        }
    }
}
